import request from '@/utils/request'

/* 获取菜品分类或者套餐分类的接口 */
export const fetchDishOrStemCategoryAPI = (type) => {
  return request({
    url: '/category/list',
    method: 'GET',
    params: {
      type
    }
  })
}

/* 获取菜品列表的接口 */
export const fetchDishListAPI = (params) => {
  return request({
    url: '/dish/page',
    method: 'GET',
    params
  })
}

/* 起售和停售菜品的接口 */
export const updateDishStatusAPI = (status, id) => {
  return request({
    url: `/dish/status/${status}`,
    method: 'POST',
    params: {
      id
    }
  })
}

/* 删除菜品的接口 */
export const deleteDishAPI = (ids) => {
  return request({
    method: 'DELETE',
    url: `/dish`,
    params: {
      ids
    }
  })
}

/* 添加菜品的接口 */
export const addDishAPI = (data) => {
  return request({
    url: '/dish',
    method: 'POST',
    data
  })
}

/* 获取菜品详情的接口 */
export const fetchDishDetailAPI = (id) => {
  return request({
    url: `/dish/${id}`,
    method: 'GET'
  })
}

/* 修改菜品的接口 */
export const updateDishAPI = (data) => {
  return request({
    url: `/dish`,
    method: 'PUT',
    data
  })
}

/* 根据分类ID获取菜品 */
export const fetchDishByIdAPI = (categoryId) => {
  return request({
    url: `/dish/list`,
    method: 'GET',
    params: {
      categoryId
    }
  })
}
